package com.baizhi.service.impl;

import com.baizhi.dao.SongDAO;
import com.baizhi.entity.Song;
import com.baizhi.service.SongService;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

@Service
@Transactional
public class songServiceImpl implements SongService {
    @Autowired
    private SongDAO songDAO;
    @Override
    public PageInfo<Song> selectAll(int page, int limit, String songName, Integer who) {
        PageHelper.startPage(page,limit);
        List<Song> songs = songDAO.selectAll(songName, who);
        PageInfo<Song> songPageInfo = new PageInfo<>(songs);
        return songPageInfo;
    }

    @Override
    public void insert(Song song) {
        songDAO.insert(song);
    }

    @Override
    public void delete(Integer id) {
        songDAO.delete(id);
    }

    @Override
    public void deleteMany(Integer[] ids) {
        songDAO.deleteMany(ids);
    }

    @Override
    public Song selectOne(Integer id) {
        Song song = songDAO.selectOne(id);
        return song;
    }

    @Override
    public void update(Song song) {
        songDAO.update(song);
    }
}
